package servlet;

import bean.Result;
import biz.CartBiz;
import com.google.gson.Gson;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "QueryCartServlet", value = "/QueryCartServlet.s")
public class QueryCartServlet extends HttpServlet {
    private CartBiz biz = new CartBiz();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        HttpSession session = request.getSession();
        String uid = String.valueOf(session.getAttribute("userid"));
        List<Map<String, Object>> res = biz.query(uid);
        String json = new Gson().toJson(res);
        response.getWriter().append(json);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
